<template>
    <div>
        <!-- 头部 -->
        <div class="Stop">
            <div class="StopO">
                <i @click="Sbackto()" class="Stfan"></i>
                <input class="StopOn" type="text" value="输入商品关键词" @click="search($event)" @input="conten($event)">
                <img class="StopOne" src="../../assets/user/top-search.png" alt="搜索">
                <p @click="Sto()" class="Stopmsg">搜索</p>
            </div> 
           
        </div>
    </div>
</template>

<script>
export default {
    name:'Top',
    data(){
        return{
            toptr:[false,false,false,false],
            txt:''
        }
    },
    methods:{
        Sbackto(){
            this.$router.replace('/');
        },
        Sto(){
            this.$router.replace('/sresult?name='+this.txt);
        },
        search(e){
            e.target.value = '';
        },
        conten(e){
            this.txt = e.target.value;
        }
    },
    mounted(){
        var href = window.location.href.split('#')[1];
        switch (href) {
            case '/':
                this.$set(this.toptr,0,true);
                break;
            case '/thoughts':
                this.$set(this.toptr,1,true);
                break;
            case '/food':
                this.$set(this.toptr,2,true);
                break;
            case '/milk':
                this.$set(this.toptr,3,true);
                break;
        }
    }
}
</script>

<style  scoped>

/* 头部 */
.Stop {
    background-color: #e53e42;
    width: 100%;
    height: 9.6rem;
    color: #fff;
    font-size: 3.6rem;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
}
.StopO {
    height:9.6rem;
    padding: 0 2rem;
    line-height: 9.6rem;
    text-align: left;
}
.StopOn {
    margin-left: 2.8rem;
    height: 4.8rem;
    width: 49.3rem;
    border-radius: 1rem;
    vertical-align: middle;
    margin-bottom: 1rem;
    padding-left: 4.7rem;
    font-size: 2.4rem;
    color: #e83d41;
}
.StopOne {
    position: absolute;
    z-index: 2;
    top: 50%;
    margin-top: -1.5rem;
    left: 8.5rem;
}
.Stopmsg {
    position: absolute;
    right: 2rem;
    top: 0;
    top: 2rem;
    margin-top: -1.9rem;
    line-height:9.6rem ;
}
/* < */
.Stfan {
    width: 2.5rem;
    height: 2.5rem;
    border-left: 0.2rem solid #fff;
    border-bottom: 0.2rem solid #fff;
    display: inline-block;
    transform: rotate(45deg);
}
</style>